package com.retail.xiaocui.server.service.impl;

import java.util.List;

import com.retail.common.core.domain.Result;
import com.retail.common.security.auth.AuthUtil;
import com.retail.common.security.utils.SecurityUtils;
import com.retail.xiaocui.common.domain.req.OrderReq;
import com.retail.xiaocui.server.look.DIstributedLockClient;
import com.retail.xiaocui.server.look.RedisLuaLook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.retail.xiaocui.server.mapper.WarehouseMapper;
import com.retail.xiaocui.common.domain.Warehouse;
import com.retail.xiaocui.server.service.WarehouseService;

/**
 * 仓库Service业务层处理
 *
 * @author retail
 * @date 2024-03-07
 */
@Service
public class WarehouseServiceImpl implements WarehouseService
{
    @Autowired
    private WarehouseMapper warehouseMapper;

    /**
     * 查询仓库
     *
     * @param warehouseId 仓库主键
     * @return 仓库
     */
    @Override
    public Warehouse selectWarehouseByWarehouseId(Integer warehouseId)
    {
        return warehouseMapper.selectWarehouseByWarehouseId(warehouseId);
    }

    /**
     * 查询仓库列表
     *
     * @param warehouse 仓库
     * @return 仓库
     */
    @Override
    public List<Warehouse> selectWarehouseList(Warehouse warehouse)
    {
        return warehouseMapper.selectWarehouseList(warehouse);
    }

    /**
     * 新增仓库
     *
     * @param warehouse 仓库
     * @return 结果
     */
    @Override
    public int insertWarehouse(Warehouse warehouse)
    {
        return warehouseMapper.insertWarehouse(warehouse);
    }

    /**
     * 修改仓库
     *
     * @param warehouse 仓库
     * @return 结果
     */
    @Override
    public int updateWarehouse(Warehouse warehouse)
    {
        return warehouseMapper.updateWarehouse(warehouse);
    }

    /**
     * 批量删除仓库
     *
     * @param warehouseIds 需要删除的仓库主键
     * @return 结果
     */
    @Override
    public int deleteWarehouseByWarehouseIds(Integer[] warehouseIds)
    {
        return warehouseMapper.deleteWarehouseByWarehouseIds(warehouseIds);
    }

    /**
     * 删除仓库信息
     *
     * @param warehouseId 仓库主键
     * @return 结果
     */
    @Override
    public int deleteWarehouseByWarehouseId(Integer warehouseId)
    {
        return warehouseMapper.deleteWarehouseByWarehouseId(warehouseId);
    }

    private static  int count=0;

    @Override
    public Result<List<Warehouse>> warehouseList() {

     List<Warehouse> list = warehouseMapper.warehouseList();
            myMethod();
        System.out.println("查询了仓库"+count);
        return Result.success(list);
    }

    public static  void myMethod(){
        count++;
    }

}
